﻿var isOnline = 1;
//var curUrl = window.location.href.toLowerCase();

//活动信息
var year = "2018";  //活动年份
var Remark = "融创9月生日会";  //活动年份
var subimitType = "1";
var name = call  = project = station = day = time = "";
var isOwner = 1;

//=========================================================授权=================================================
/*定义服务号ID*/
var authOpenID = "gh_db98c1853c28";
var shareOpenID = "gh_e89dba73fb6f";

/*保存微信信息到目标服务器*/
function saveWechatInfo(openid, nickname, headimg) {
//					pWidget.showLoading();
	$.ajax({
		type: "Post",
		url: "../ysjvk0114/WebServices/Ajax.aspx",
		data: {
			"Cmd": "inquireabout",
			"OpenID": openid
		},
		dataType: "json",
		async: false,
		cache: false,
		beforeSend: function() {},
		success: function(result) {
			$("#loading").remove();
			//clearInterval(loadTime);
			if(result.ErrorCode == 1) {
				//已报名
				name = unescape(result.rows[0].Name);
				call = result.rows[0].PhoneNumber;
				isOwner = result.rows[0].isOwner;
				$(".project,.station,.day,.time").hide();
				$(".info_project,.info_station,.info_time,.info_day").show();
				if(isOwner == 1){
					project = unescape(result.rows[0].project);
					$(".info_project").html(project);
				}else{
					$(".is_owner").css("background-image","url(img/choose_n.png)");
					$(".no_owner").css("background-image","url(img/choose_y.png)");
					$(".project_box").hide();
					$(".station_box,.time_box,.sub_btn,.bottom_text").addClass("up");
				}
				station = unescape(result.rows[0].station);
				day = unescape(result.rows[0].day);
				time = unescape(result.rows[0].time);
				$(".name").val(name);
				$(".call").val(call);
				$(".info_station").html(station);
				$(".info_day").html(day);
				$(".info_time").html(time);
				$(".mask").show();
				$('.sub_btn').hide();
				return;
			} else if(result.ErrorCode == 2) {
				//未报名
				//此处返回状态为巢提交成功，并且会返回一个名为rows的json数组，捰组内容是所填写的内容
			} else {
				pWidget.alert ("活动已结束");
				return;
			}
			
			
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
//							pWidget.hideLoading();
			pWidget.alert(XMLHttpRequest.responseText);
		}
	});
	
}

function alertTips() {
    alert("本活动处于测试阶段，\r\n请勿转发朋友圈！");
}

$(document).ready(function () {
	
    if (isOnline == 0) {
        alertTips();
    }
    // alert('本次活动已结束,感谢您的关注!');


});


//分享的成功后调用的方法
wx_share.success(function () {
    //    alert('分享成功！');
});
//分享的失败后调用的方法
wx_share.cancel(function () {
    //    alert('分享取消！');
});


//检查姓名输入是否正确
function checkName(nameid, nametipid) {
	var name = document.getElementById(nameid);
	name.value = name.value.replace(/\s/gi, "");
	if($("#" + nameid + "").val() == "" || $("#" + nameid + "").val() == "请输入您的中文姓名") {
		//$("." + nametipid + "").show();
		//$("." + nametipid + "").attr("src", "images/false.png");
		// alert("请输入您的姓名");
		pWidget.alert("请输入您的姓名");
		return false;
	} else {
		var zhengze = eval('/^[\\u4e00-\\u9fa5]{2,6}$/');
		var yanzheng = zhengze.exec(name.value);
		if(yanzheng) {
			//$("." + nametipid + "").show();
			//$("." + nametipid + "").attr("src", "images/true.png");
			return true;
		} else {
			pWidget.alert("姓名输入有误，格式为2—6位中文汉字");
			// alert("姓名输入有误，格式为2—6位中文汉字");
			//$("." + nametipid + "").show();
			//$("." + nametipid + "").attr("src", "images/false.png");
			return false;
		}
	}
}

//检查手机号码输入是否正确
function checkMobilePhone(MobileId, MotipId) {
	var mobilePhone = document.getElementById(MobileId);
	mobilePhone.value = mobilePhone.value.replace(/\s/gi, "");
	if($("#" + MobileId + "").val() == "" || $("#" + MobileId + "").val() == "请输入您的手机号码") {
		//$("." + MotipId + "").show();
		//$("." + MotipId + "").attr("src", "images/false.png");
		pWidget.alert("请输入您的手机号码");
		return false;
	} else {
		var zhengze = eval('/^1[3,4,5,7,8]{1}[0-9]{9}$/');
		var yanzheng = zhengze.exec(mobilePhone.value);
		if(yanzheng) {
			//$("." + MotipId + "").show();
			//$("." + MotipId + "").attr("src", "images/true.png");
			return true;
		} else {
			//$("." + MotipId + "").show();
			//$("." + MotipId + "").attr("src", "images/false.png");
			pWidget.alert("手机号码输入有误，请重新输入");
			return false;
		}
	}
}